/**
 * @author xuyuhang
 */

var newer = newer || {};
newer.gd = newer.gd || {};

newer.ToolBarButton = function(o) {
	this.domNode = o.domNode;
	
	this.idSuffix = (o.idSuffix!=undefined)?o.idSuffix:"";
	
	this.title = o.title;
	this.clickHandler = o.clickHandler;
	this.mouseenterHandler = (o.mouseenterHandler!=undefined)?o.mouseenterHandler:this.mouseEnter;
	this.mouseleaveHandler = (o.mouseleaveHandler!=undefined)?o.mouseleaveHandler:this.mouseLeave;
	
	this.init();
};

newer.ToolBarButton.prototype = {
	init: function() {
		this.domNode.html('<a href=""><div class="tool-bar-button-container">'+this.title+'</div></a>');
		
		this.domNode.on("click", this.clickHandler).addClass("link-like-element");
		
		// bind mouse enter and leave effect
		this.domNode.on("mouseenter", $.proxy(this.mouseenterHandler, this));
		this.domNode.on("mouseleave", $.proxy(this.mouseleaveHandler, this));
		
		this.refresh();
	},
	
	refresh: function() {
			
	},
	
	mouseEnter: function() {
		// this.domNode.css({"background-color":"#def"});
		this.domNode.css({"box-shadow":"inset 0px 0px 4px 2px rgba(0,0,0,0.5)"});
	},
	
	mouseLeave: function() {
		// this.domNode.css({"background-color":"transparent"});
		this.domNode.css({"box-shadow":""});
	}
}